import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;


public class Images {
	
	private BufferedImage webcam, map;
	
	public Images() throws IOException
	{
		//should set some default images 
		webcam = ImageIO.read(new File("image.png"));
		map = ImageIO.read(new File("image.png"));
	}
	
	public void setWebcamImage(BufferedImage webcam)
	{
		this.webcam = webcam;
	}
	
	public void setMapImage(BufferedImage map)
	{
		this.map = deepCopy(map);
	}
	
	public BufferedImage getWebcamImage()
	{
		return webcam;
	}
	
	public BufferedImage getMapImage()
	{
		return map;
	}
	/*
	 * URL : http://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage
	 */
	private static BufferedImage deepCopy(BufferedImage bi) {
		 ColorModel cm = bi.getColorModel();
		 boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
		 WritableRaster raster = bi.copyData(null);
		 return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
		}

}
